/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Server;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;

/**
 *
 * @author INFORMATICA
 */
public class Archivo {
    
    public void guardar(String direccion, Object objeto) throws FileNotFoundException, IOException
    {
        FileOutputStream fileOut=new FileOutputStream(direccion);
        ObjectOutputStream salida=new ObjectOutputStream(fileOut);
         salida.writeObject(objeto);
    }
    public Object Leer(String direccion) throws FileNotFoundException, IOException, ClassNotFoundException
    {
     FileInputStream fileIn=new FileInputStream(direccion);
     ObjectInputStream entrada=new ObjectInputStream(fileIn);
     return entrada.readObject();
    }
    
    public String Eliminar(String direccion)
     {
         File fichero = new File(direccion);
         if (fichero.delete())
         return "El fichero ha sido borrado satisfactoriamente";
          else
          return "El fichero no puede ser borrado";
      }
}
